﻿using ZingBlog.Domain.Entities;
using ZingBlog.Dto;
using ZingBlog.IService;

namespace ZingBlog.Service
{
    public class LogService : BaseService<LogEntity>, ILogService
    {

        public bool WriteDbLog(LogEntity Entity)
        {
            Entity.Status = true;
            Entity.CreateOn = DateTime.Now;
            return baseRepository.Create(Entity) > 0 ? true : false;
        }
        public dynamic GetListByFilter(LogEntity filter, PageInfo pageInfo)
        {
            string _where = " where 1=1";
            if (!string.IsNullOrEmpty(filter.RealName))
            {
                _where += " and RealName=@RealName";
            }
            if (!string.IsNullOrEmpty(filter.UserName))
            {
                _where += " and UserName=@UserName";
            }
            _where = CreateWhereStr(filter, _where);
            return GetListByFilter(filter, pageInfo, _where);
        }
    }
}
